package com.bwie.controller;

import com.bwie.pojo.Booking;
import com.bwie.pojo.Clique;
import com.bwie.pojo.Product;
import com.bwie.pojo.vo.VoClass;
import com.bwie.service.EventsService;
import com.bwie.service.IUserService;
import com.bwie.service.ProductService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/prod/prod")
public class ProductController {

    @Autowired
    ProductService productService;

    @Autowired
    IUserService iUserService;

    @Autowired
    EventsService eventsService;

    /**
     * 熔断接口
     * @param id
     * @return
     */
    @PostMapping("/userById/{id}")
    public R userById (@PathVariable Integer id) {
        return iUserService.userById(id);
    }

    /**
     * 商品分页列表接口
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/prodList")
    public R prodList (@RequestBody @Validated PageInfoVo pageInfoVo) {
        return productService.prodList(pageInfoVo);
    }

    /**
     * 活动分页列表接口
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/eventsList")
    public R eventsList (@RequestBody @Validated PageInfoVo pageInfoVo) {
        return eventsService.eventsList(pageInfoVo);
    }

    /**
     * 添加商品列表接口
     * @param product
     * @return
     */
    @PostMapping("/saveProd")
    public R saveProd (@RequestBody @Validated Product product) {
        return productService.saveProd(product);
    }

    /**
     * 添加成团接口
     * @param voClass
     * @return
     */
    @PostMapping("/saveProductAll")
    public R saveProductAll (@RequestBody @Validated VoClass voClass) {
        return productService.saveProductAll(voClass);
    }

    /**
     * 根据ID查询列表
     * @param id
     * @return
     */
    @PostMapping("/selProdById/{id}")
    public R selProdById (@PathVariable Integer id) {
        return productService.selProdById(id);
    }

    /**
     * 加入团接口
     * @param id
     * @return
     */
    @PostMapping("/updBookById/{id}")
    public R updBookById (@PathVariable Integer id) {
        return productService.updBookById(id);
    }

    /**
     * 个人开团
     * @param clique
     * @return
     */
    @PostMapping("/saveClique")
    public R saveClique (@RequestBody @Validated Clique clique) {
        return productService.saveClique(clique);
    }

    /**
     * 个人开团列表
     * @return
     */
    @PostMapping("/cliqueList")
    public R cliqueList () {
        return productService.cliqueList();
    }
}
